﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_BGM_ProjectOperationExpense : IBLL_BGM_ProjectOperationExpense
    {
        Common common = new Common();
        private static readonly IDAL_BGM_ProjectOperationExpense dal = DataAccess.Create_BGM_ProjectOperationExpense();

        public B_BGM_ProjectOperationExpense()
        {

        }

        public IList<M_BGM_ProjectOperationExpense> GetFull(string bgm_proj_oper_seq
            , string bgm_source_seq, string bgm_exp_grp_seq)
        {
            Nullable<int> nbgm_project_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_exp_grp_seq = common.ConvertNullInt(bgm_exp_grp_seq);
            return dal.GetFull(nbgm_project_seq, nbgm_source_seq, nbgm_exp_grp_seq);
        }

        public IList<M_BGM_ProjectOperationExpense> GetProjectExpense(string bgm_proj_oper_seq
            , string bgm_proj_seq)
        {
            Nullable<int> nbgm_project_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_proj_seq = common.ConvertNullInt(bgm_proj_seq);
            return dal.GetProjectExpense(nbgm_project_seq, nbgm_proj_seq);
        }

        public IList<M_BGM_ProjectOperationExpense> GetList(string bgm_proj_oper_seq
            , string bgm_source_seq, string bgm_exp_grp_seq)
        {
            Nullable<int> nbgm_project_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_exp_grp_seq = common.ConvertNullInt(bgm_exp_grp_seq);
            return dal.GetList(nbgm_project_seq, nbgm_source_seq, nbgm_exp_grp_seq);
        }

        public IList<M_BGM_ProjectOperationExpense> GetGroupBgmSource(string bgm_proj_oper_seq)
        {
            Nullable<int> nbgm_proj_oper_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            return dal.GetGroupBgmSource(nbgm_proj_oper_seq);
        }

        public IList<M_BGM_ProjectOperationExpense> GetGroupBgmExpGrp(string bgm_proj_oper_seq
            , string bgm_source_seq)
        {
            Nullable<int> nbgm_proj_oper_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            return dal.GetGroupBgmExpGrp(nbgm_proj_oper_seq, nbgm_source_seq);
        }

        public IList<M_BGM_ProjectOperationExpense> GetGroupBgmExp(string bgm_proj_oper_seq
            , string bgm_source_seq, string bgm_exp_grp_seq)
        {
            Nullable<int> nbgm_proj_oper_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_exp_grp_seq = common.ConvertNullInt(bgm_exp_grp_seq);
            return dal.GetGroupBgmExp(nbgm_proj_oper_seq, nbgm_source_seq, nbgm_exp_grp_seq);
        }

        public M_BGM_ProjectOperationExpense GetInfo(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public bool CheckAmount(int bgm_proj_oper_exp_seq, double amount)
        {
            return dal.CheckAmount(bgm_proj_oper_exp_seq, amount);
        }

        //public string SelectRecentInsertedRoleSeq()
        //{
        //    return dal.SelectRecentInsertedRoleSeq();
        //}

        public string Insert(M_BGM_ProjectOperationExpense info)
        {
            try
            {
                return dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_BGM_ProjectOperationExpense info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_BGM_ProjectOperationExpense info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }
    }
}
